import { request } from '@/utils/http';
import { API, BaseModel } from '../model/baseModel';
import { UserPickerModel } from '@/services/model/formModel';

/**
 * 获取用户所属部门
 * @param userId 用户id
 * @returns 部门信息
 */
export function getUserDepts(userId: string) {
  return request.get<API<BaseModel[]>>(`/oa/org/user/${userId}/dept`);
}

/**
 * 获取部门下的部门和用户
 * @param deptId 部门id
 * @returns 部门和用户
 */
export function getUserTree(deptId: string) {
  return request.get<API<UserPickerModel[]>>(`/sys/user/tree?type=user&deptId=${deptId}`);
}

/**
 * 获取部门下的部门
 * @param deptId 部门id
 * @returns 部门
 */
export function getDeptTree(deptId: string) {
  return request.get<API<UserPickerModel[]>>(`/sys/user/tree?type=dept&deptId=${deptId}`);
}
